if orders and not orders.InitSemafore then


function orders:InitSemafore()
	if not orders.sem_queue then
		orders.sem_queue = "orders.queue." .. lib:GetUser()
	end
	--if not orders.sem_sent then
	--	orders.sem_sent = "orders.sent." .. lib:GetUser()
	--end
end


function orders:lock_queue()
	self:InitSemafore()
	
	--if self.transactions.count == 0 and self.orders.count == 0 then
		return lib:lock(orders.sem_queue)
	--end
end


function orders:unlock_queue()
	self:InitSemafore()
	
	--if self.transactions.count == 0 and self.orders.count == 0 then
		lib:unlock(orders.sem_queue)
	--end
end


function orders:locked_queue()
	self:InitSemafore()
	
	return lib:locked(orders.sem_queue)
end

--[[
function orders:lock_sent(id)
	self:InitSemafore()
	
	return lib:lock(orders.sem_sent, id)
end


function orders:unlock_sent(id)
	self:InitSemafore()
	
	lib:unlock(orders.sem_sent, id)
end


function orders:locked_sent(id)
	self:InitSemafore()
	
	return lib:locked(orders.sem_sent, id)
end
--]]

function orders:InProcess()
	--if self.transactions.count > 0 then
	--	return self.transactions
	--end
	--if self.orders.count > 0 then
	--	return self.orders
	--end
	
	return self.transactions.count > 0 or self.orders.count > 0 or self:locked_queue() --or self:locked_sent()
	
	--return self:locked_queue()
end


function orders:WaitProcess()
	while self:InProcess() do
		sleep(200)
	end
end


end -- of file
